package cn.tedu._01mvcboot01.controller;

import cn.tedu._01mvcboot01.pojo.dto.CarAddDTO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class CarController {
    @RequestMapping("/add1")
    @ResponseBody
    public String add1(String brand,String model,Double price)
    {
        System.out.println(brand + "-" + model + "-" + price);
        return "add successfully";
    }
    // 前后端传参的第二种方式 直接用DTO对象来接收前端传来的数据  也应该注意字段名一致
    @RequestMapping("/add2")
    @ResponseBody
    public String add2(CarAddDTO addDTO)
    {
        System.out.println(addDTO.toString());
        return addDTO.toString();
    }

}
